package algorithm.easy;

import pojo.TreeNode;

public class EvaluateTree2331 {
    public boolean evaluateTree(TreeNode root) {
        //叶子节点返回本身值
        if (root.left == null && root.right == null) {
            return root.val == 1;
        }
        //根节点返回两个叶子节点的计算结果
        if (root.val == 2) {
            return evaluateTree(root.left) || evaluateTree(root.right);
        }else {
            return evaluateTree(root.left) && evaluateTree(root.right);
        }
    }
}
